import network
import time



def demo():
    lte = network.LTE()
    if not lte.isconnected():
        #print("Connecting to eth...")
        lte.active(True)
        lte.connect()
        # 循环等待直到连接成功
        time.sleep_ms(500)
        if lte.isconnected():
            print("4G connected",lte.status())
            csq = lte.csq()
            iccid = lte.iccid()
            version = lte.version()
            imei = lte.imei()
            print('''csq:{}\niccid:{}\nversion:{}\nimei:{}'''.format(csq,iccid,version,imei))
            ret = lte.ppp_stop()
            print(ret)
            ret = lte.ppp_start()
            print(ret)
            lte.reset()
            lte.apn('param')
            time.sleep(3)

if __name__ == '__main__':
    demo()